1 00:00:00,600 --> 00:00:01,980 Hello and welcome him. 2 00:00:01,990 --> 00:00:02,960 They feed you. 3 00:00:03,180 --> 00:00:11,330 I will be adding the javascript functionality that will make the application work. 4 00:00:11,580 --> 00:00:15,010 So let's create our javascript farm. 5 00:00:15,080 --> 00:00:22,190 We've already made a reference to it inside our script from the Hey Tim a file and a poor deep quartz 6 00:00:22,320 --> 00:00:23,620 Duchess. 7 00:00:23,650 --> 00:00:27,220 Someone to click on a file option in sublime Tex. 8 00:00:27,360 --> 00:00:28,550 Go new. 9 00:00:28,950 --> 00:00:33,370 And I'm going to save this new file. 10 00:00:33,690 --> 00:00:35,210 Java script files. 11 00:00:35,220 --> 00:00:43,750 I'm going to call it quits g s and to select the drop down here. 12 00:00:43,860 --> 00:00:45,420 Make sure I select. 13 00:00:45,420 --> 00:00:47,450 He checked my scrip far. 14 00:00:47,980 --> 00:00:50,340 All right so I'll say that. 15 00:00:50,610 --> 00:00:58,140 So I now have a javascript file send anything you can see here on the bottom right hand corner says 16 00:00:58,140 --> 00:01:00,390 javascript as well. 17 00:01:00,660 --> 00:01:04,200 The first thing I want to do is create an array. 18 00:01:04,480 --> 00:01:13,620 And now really am going to use the every tool hold the values of the quotes so to define our and a first 19 00:01:13,620 --> 00:01:14,850 for create a variable. 20 00:01:14,860 --> 00:01:26,160 OK call the artful variable and I'm going to call it Harry off quotes. 21 00:01:26,310 --> 00:01:29,640 Note is the use of -- will case come will cause. 22 00:01:29,650 --> 00:01:37,650 Basically means the first letter of the first word is lower case and then the first letter of or the 23 00:01:37,690 --> 00:01:40,020 subsequent words are in upper case. 24 00:01:40,020 --> 00:01:45,870 He can see the all his PA and the Q in chords is up right. 25 00:01:45,880 --> 00:01:50,150 Some will accept that to equal to an array. 26 00:01:50,160 --> 00:01:54,510 This is how you define an array in square brackets. 27 00:01:54,690 --> 00:02:06,390 So in between this array here is where I'm going to place the books so you can select your own favourite 28 00:02:06,390 --> 00:02:06,860 quotes. 29 00:02:06,860 --> 00:02:11,530 You don't have to use mine so these are just some of my favourite quotes. 30 00:02:11,630 --> 00:02:16,400 I'm going to just paste that him inside this Arri. 31 00:02:16,620 --> 00:02:24,550 So these are the quotes that will be randomly generated when you click on the button so they're good 32 00:02:24,620 --> 00:02:31,110 having close them inside an array you can see that the opening array which is the square bracket and 33 00:02:31,110 --> 00:02:32,930 this is the closing array. 34 00:02:33,210 --> 00:02:35,130 So does good true. 35 00:02:35,130 --> 00:02:43,530 Just one of the quotes I got through the first one here so you can see here. 36 00:02:43,770 --> 00:02:47,410 I got to Arthur because the text. 37 00:02:47,420 --> 00:02:50,490 We need to include text in quotes. 38 00:02:50,550 --> 00:02:58,950 Some got it off or here and after that I got a call on and then we have the name of the author and then 39 00:02:59,040 --> 00:02:59,730 a comma. 40 00:02:59,840 --> 00:03:07,560 Notice I have enclosed everything inside opening curly braces and closing curly braces and there is 41 00:03:07,650 --> 00:03:11,400 a comma which is important whenever you put a comma. 42 00:03:11,400 --> 00:03:13,450 That means you've got more to come. 43 00:03:13,690 --> 00:03:17,670 So here this is the first quote here. 44 00:03:17,730 --> 00:03:21,660 This is the second quote so h in between is curly braces. 45 00:03:21,660 --> 00:03:29,850 You have to offer and then you have the name of the offer and then you have the actual quote itself. 46 00:03:29,850 --> 00:03:35,290 Notice is very important to note is the chords are closed. 47 00:03:35,310 --> 00:03:37,270 Each of the parts. 48 00:03:37,500 --> 00:03:38,550 So the aha. 49 00:03:38,580 --> 00:03:45,440 You've got quotes and then call on and then you've got the output of what you've got chords rounded 50 00:03:45,540 --> 00:03:49,520 and then come very important because you miss out the comma. 51 00:03:49,650 --> 00:03:58,970 It will not work properly so make sure you place a comma after each of the hotels name and then comma. 52 00:03:58,980 --> 00:04:06,750 Also at the end of the closing calibrates this is the only place where you don't need to place a comma 53 00:04:06,800 --> 00:04:10,140 is the final curly braces. 54 00:04:10,140 --> 00:04:16,630 So the last quote You don't need to put a comma on the last curly braces or the others. 55 00:04:16,650 --> 00:04:20,460 Put a comma up but the loss very important. 56 00:04:20,700 --> 00:04:26,210 But you must put a comma after the name of the author. 57 00:04:26,470 --> 00:04:31,520 All right so we got voler Use just a sample here. 58 00:04:31,530 --> 00:04:38,550 You can make these as long as you want add as many quotes as you want as long as you have it in close 59 00:04:38,640 --> 00:04:39,870 inside the hurry. 60 00:04:39,870 --> 00:04:41,750 That should be fine. 61 00:04:41,790 --> 00:04:49,040 Also make sure that each of the auto name has a comma after the name. 62 00:04:49,080 --> 00:04:50,150 Put a comma. 63 00:04:50,350 --> 00:04:58,930 I've tidied Kobe braces put a comma behind the plate is only the comma is the last is the last of. 64 00:04:59,130 --> 00:04:59,880 So this is the. 65 00:04:59,950 --> 00:05:03,500 Last one here so I don't need a curlee DONE. 66 00:05:03,820 --> 00:05:08,680 However if I decided I wanted to add more quotes on then I would need took place. 67 00:05:08,680 --> 00:05:11,900 They've come out there and add more coats. 68 00:05:11,930 --> 00:05:14,920 So that is the tree. 69 00:05:15,310 --> 00:05:24,940 The next thing I want to do is create a function that wall rung donnelly select each of the quotes using 70 00:05:24,940 --> 00:05:34,230 the length of the ring and we are going to be using the maths random method and I will lend basically 71 00:05:34,300 --> 00:05:39,670 refers to the values inside the array. 72 00:05:39,760 --> 00:05:50,360 It begins with is zero index So for example this one here will be referred to as 0 1 2 3 4 and so on. 73 00:05:50,950 --> 00:05:59,320 So just underneath the close in array here add a function of cordy's Random select and I've passed it 74 00:05:59,590 --> 00:06:08,230 this parameter out of our real length our relend basically ref determines or makes reference to the 75 00:06:08,230 --> 00:06:10,240 values inside the rate. 76 00:06:10,480 --> 00:06:15,070 So the very first value is going to be zero. 77 00:06:15,070 --> 00:06:18,580 This would be 0 1 2 3 4 and so on. 78 00:06:18,580 --> 00:06:27,610 That's what the relend is referring to and is going to return a value it's going to return mass floor 79 00:06:28,750 --> 00:06:38,350 mass of flood basically is going to be to around in number downwards to is near S integer. 80 00:06:38,360 --> 00:06:47,500 All right so the masteroff floor rounded number up to the nearest integer M. at random or randomly generate 81 00:06:47,650 --> 00:06:52,150 random numbers based on the re length. 82 00:06:52,210 --> 00:06:57,420 So next time I want to do is create a function Hord generate quote. 83 00:06:57,670 --> 00:07:05,540 So if we look inside the hate mail here we already made reference to this function code generate code. 84 00:07:05,560 --> 00:07:12,400 This is going to be this function here is already attached to the button which is the unclick method 85 00:07:12,400 --> 00:07:17,050 so when you click on the button it will call this function so that's a function. 86 00:07:17,060 --> 00:07:26,080 I am going to create now just going to add it on the the random select off are right so I added a function 87 00:07:26,110 --> 00:07:26,550 call. 88 00:07:26,560 --> 00:07:27,980 Generate quote. 89 00:07:28,020 --> 00:07:32,020 So this is a function that will be called upon. 90 00:07:32,080 --> 00:07:40,360 When you click on the button inside the hastier mail so the name is generate quotes and in between the 91 00:07:40,360 --> 00:07:44,110 curly braces is the code that will execute. 92 00:07:44,110 --> 00:07:51,540 So here we've got a variable called random number and I've set that too of course for the random select 93 00:07:51,850 --> 00:07:58,350 which is this function here and then inside the parentheses part in the Re. 94 00:07:58,390 --> 00:08:02,460 Of course the array of quotes is this variable. 95 00:08:02,460 --> 00:08:11,130 Here I have created some passing that value has a parameter bear and I attached the left leg. 96 00:08:11,150 --> 00:08:16,290 Basically it will determine how many awards there are in the array. 97 00:08:16,480 --> 00:08:19,570 So the very first call would be zero. 98 00:08:19,790 --> 00:08:21,920 And the last or B. 99 00:08:22,000 --> 00:08:24,620 So you start from zero and one saw. 100 00:08:24,680 --> 00:08:32,890 Okay so the Lend Me refers to the length of the courts have this how many quotes you have in the array. 101 00:08:32,890 --> 00:08:34,150 That's what that means. 102 00:08:34,480 --> 00:08:38,730 And then we use in the document to get a lemon about a Dementor out. 103 00:08:38,950 --> 00:08:47,190 So this basically which is a quote outport in this here is inside his team which is this quote put here. 104 00:08:47,470 --> 00:08:51,770 That's what's his refrain to us all we getting that idea called Court our. 105 00:08:52,090 --> 00:08:58,630 And we are replacing it content with this in the hastier mail yes you see here this code here. 106 00:08:58,630 --> 00:09:06,780 Basically we are replacing it with the quotes that will be generated create to create a space plus the 107 00:09:06,830 --> 00:09:11,020 array of quotes which is this here plus the random number. 108 00:09:11,200 --> 00:09:19,510 Okay so each of the quotes will be a randomly assigned number based on the length of the quotes in the 109 00:09:19,510 --> 00:09:20,120 array. 110 00:09:20,380 --> 00:09:22,160 So the random number will be. 111 00:09:22,180 --> 00:09:29,910 So he told for example he can randomly select this or 4 here or this quote and it all. 112 00:09:29,920 --> 00:09:39,870 Then attach the quote bloss whatever the court says and then here Line 6 is to again we use the documents 113 00:09:39,940 --> 00:09:40,760 element. 114 00:09:40,870 --> 00:09:42,650 Here we are going to. 115 00:09:42,670 --> 00:09:46,790 This is where we're going to put the author. 116 00:09:46,990 --> 00:09:50,490 Okay so if we go into the hastier mail we've got this idea here. 117 00:09:50,500 --> 00:09:56,780 So basically it all Take all that this paragraph and inject the author here. 118 00:09:56,890 --> 00:09:57,700 That's what that is. 119 00:09:57,700 --> 00:09:59,830 So who's going to just replace. 120 00:09:59,940 --> 00:10:08,720 Whatever content you have inside this paragraph all these idae and replace it will be actual quote and 121 00:10:08,830 --> 00:10:15,660 the OT and the name of the heart or so to grab the quote from the random number assigned to the court 122 00:10:16,110 --> 00:10:20,610 and also attach the name of the author to the court. 123 00:10:20,640 --> 00:10:23,680 So that's basically what this function with. 124 00:10:23,730 --> 00:10:30,640 So this is the function that would do a lot of the heavy lifting for the application time because looks 125 00:10:30,740 --> 00:10:38,340 look on the save option and then we can test the application someone to click on the tree here 126 00:10:40,650 --> 00:10:47,730 and double click on the quotes hastier CML when youre running your projet you always have to run the 127 00:10:47,760 --> 00:10:51,790 hastier mouth not the SS or the javascript. 128 00:10:52,050 --> 00:10:58,740 They are already linked to the hedge titmouse or double click on the team now and you issue get the 129 00:10:59,250 --> 00:11:00,350 application like. 130 00:11:00,390 --> 00:11:01,970 So this is the application now. 131 00:11:01,980 --> 00:11:04,110 So if everything works out fine. 132 00:11:04,440 --> 00:11:09,260 If there are no errors in my javascript I should be able to click on the button. 133 00:11:09,400 --> 00:11:12,930 You can see the keywords generated in C. 134 00:11:13,080 --> 00:11:15,740 Right so everything is working. 135 00:11:15,750 --> 00:11:17,160 Has design. 136 00:11:17,340 --> 00:11:24,760 Okay so if I click I get a new word each time so that is it for this application. 137 00:11:24,810 --> 00:11:26,020 Thank you for watching. 138 00:11:26,040 --> 00:11:28,840 If you have any problems please to let me know. 139 00:11:28,860 --> 00:11:29,800 Thanks. 140 00:11:29,970 --> 00:11:31,040 All the best.